<?php

namespace lisfw;

class App {
    //项目初始化操作
    public function _init()
    {
        //1.设置头信息
        $this->_setHeader();
        //2.载入配置和系统文件
        $this->_setFile();
        //3.自动加载文件
        $this->_setAutoload();

        //4.加载composer 扩展库
        //$this->_setVendor();

        //5.路由设置
        $this->_setRoute();
    }
    
    //设置头信息
    private function _setHeader($type = 'text/html')
    {
        header('Content-type:'. $type . '; charset = utf-8');
    }

    //载入配置和系统文件
    private function _setFile()
    {
        $GLOBALS['config'] = require_once __DIR__ . '/../config/config.php';
        require_once __DIR__ . '/common.php';
    }
    //自动加载文件
    private function _setAutoload()
    {
        require_once __DIR__ . '/Autoload.php';
        //(new Autoload())->register();
        //require_once __DIR__ . '/../vendor/autoload.php';
    }

    private function _setVendor()
    {
        require_once __DIR__ . '/../vendor/autoload.php';
    }
    //路由的设置
    private function _setRoute()
    {
        require_once __DIR__ . '/Route.php';
        (new Route())->parse();
    }
}
